Vue.component('xcform_control_input_text', {
    template: '<el-form-item \
                  :class="value.fieldjsonObj.xcform_prop_required.value?\'required\':\'\'"\
                  :prop="value.fieldcode" \
                  :rules="control.rules"\
                  :label="value.fieldtitle"> \
                  <el-input type="textarea" v-model="value.value" show-word-limit clearable \
                      :placeholder="value.fieldjsonObj.xcform_base_placeholder.value" \
                      :rows="value.fieldjsonObj.xcform_base_property_input_text.rows" \
                      :maxlength="value.fieldjsonObj.xcform_prop_stringlength.value?value.fieldjsonObj.xcform_prop_stringlength.maxlength:null" \
                      :minlength="value.fieldjsonObj.xcform_prop_stringlength.value?value.fieldjsonObj.xcform_prop_stringlength.minlength:null" \
                      :disabled="control.disabled"></el-input> \
                </el-form-item>',
    props: {
        value: {
            type: Object,
        },
        disabled: {
            type: Boolean,
        },
        fieldfulljson: {
            type: Array,
        },
        xcform_id: {
            type: Number,
        }
    },
    data() {
        var validateFunction = (rule, value, callback) => {
            var that = this;
            that.value.value = (that.value.value) ? that.value.value : "";

            if (that.value.fieldjsonObj.xcform_prop_required.value) {
                if (that.value.value.length == 0) {
                    return callback(new Error('不能为空'));
                }
            }

            if (that.value.fieldjsonObj.xcform_prop_stringlength.value) {
                if (that.value.value.length < that.value.fieldjsonObj.xcform_prop_stringlength.minlength) {
                    return callback(new Error('输入内容长度必须大于' + that.value.fieldjsonObj.xcform_prop_stringlength.minlength));
                }
            }

            return callback();
        };
        return {
            control: {
                disabled: false,
                rules: [{
                    validator: validateFunction,
                    trigger: 'blur'
                }]
            }
        };
    },
    created() {
        var that = this;
        that.control.disabled = that.disabled;
        if (that.value.fieldjsonObj.xcform_prop_readonly.value) {
            that.control.disabled = true;
        }
    },
    mounted() {
        var that = this;
    },
    methods: {}
});